// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import com.nokia.meego 1.0

Component{
    id: mydelegate
    Rectangle{
        id: rectangle_content
        width: 500
        height: /*subTitle.height + 60*/150
        anchors.right: parent.right
        anchors.left: parent.left
        color: "transparent"

        Rectangle{
            id: rectangle_title
            height: 22
            color: "#db667c"
            anchors.left: parent.left
            anchors.leftMargin: 0
            anchors.right: parent.right
            anchors.rightMargin: 1
            opacity: 0.6
            Text {
                id: title
                text: "#"+id+"("+commentaire+")" + " " + author
                font.pixelSize: 15
                font.bold: true
            }
            Text {
                id: info
                x: 292
                text: date
                verticalAlignment: Text.AlignVCenter
                anchors.bottom: parent.bottom
                anchors.bottomMargin: 0
                anchors.top: parent.top
                anchors.topMargin: 0
                anchors.right: parent.right
                anchors.rightMargin: 0
                horizontalAlignment: Text.AlignHCenter
                font.pixelSize: 11
            }
        }
//            Rectangle{
//                id: subTitle
//                height: 50
//                radius: 15
//                color: "white"
//                width: 500
//                anchors.top: rectangle_title.bottom
//                anchors.topMargin: 0
//                anchors.left: parent.left
//                anchors.right: parent.right
//                Text {
//                    id: textarea
//                    anchors.rightMargin: 5
//                    anchors.bottomMargin: 5
//                    anchors.leftMargin: 5
//                    anchors.topMargin: 5
//                    anchors.fill: parent
//                    font.pixelSize: 16
//                    font.bold: false
//                    wrapMode: Text.WordWrap
//                    text: texte
////                    height: 100
//                }

//            }
        MyTextArea{
            id: subTitle
                height: 100
            text: texte
            anchors.top: rectangle_title.bottom
            anchors.topMargin: 0
            anchors.left: parent.left
            anchors.right: parent.right

//                wrapMode: Text.WordWrap
//                    anchors.fill: parent
//                font.pixelSize: 16
//                readOnly: true
        }
//                TextArea{
//                        id: subTitle
//                        text: texte
//                        wrapMode: Text.WordWrap
//                        anchors.left: parent.left
//                        anchors.right: parent.right
//                        anchors.top: rectangle_title.bottom
//                        anchors.topMargin: 0
//                        font.pixelSize: 16
//                        readOnly: true

//                    }
        Button{
            id: rectangle_agreeVDM
            width: 150
            height: 30
            anchors.top: subTitle.bottom
            anchors.left: parent.left
            anchors.leftMargin: 20


            Text {
                id: nbAgree
                text: "Je valide: " + "<b>" + agree +"<\b>"
                anchors.verticalCenter: parent.verticalCenter
                anchors.horizontalCenter: parent.horizontalCenter
                horizontalAlignment: Text.AlignHCenter
                font.pixelSize: 13
            }
        }
        ToolIcon{
            id: button_share
            width: 20
            height: 20
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 10
            platformIconId: "toolbar-share"
//                onClicked: console.debug("Share " + id)
            onClicked: {
//                    Variable.setLinkVDM(lien)
//                    Variable.setStringVDM(texte)
                (share_menu.status === DialogStatus.Closed) ? share_menu.open() : share_menu.close()
            }

        }
//            TextArea{
//                id: area_link
//                text: lien
//                visible: false
//            }
        Button{
            id: rectangle_deservedVDM
            width: 150
            height: 30
            anchors.top: subTitle.bottom
            anchors.right: parent.right
            anchors.rightMargin: 20
            Text {
                id: nbDeserved
                text: "Tu l'as bien mérité: " + "<b>"+ deserved + "<\b>"
                anchors.verticalCenter: parent.verticalCenter
                anchors.horizontalCenter: parent.horizontalCenter
                horizontalAlignment: Text.AlignRight
                font.pixelSize: 13
            }
        }
        MouseArea {
            id: mouse
            anchors.bottom: rectangle_agreeVDM.top
            anchors.right: parent.right
            anchors.left: parent.left
            anchors.top: parent.top
            anchors.bottomMargin: 10
            onClicked: {
//                    load("http://api.fmylife.com/view/"+id+"?key=4fd9d0cb0463c&language=fr")
                console.debug(textarea.height + " x " + textarea.width)
            }
        }
        Menu {
            id: share_menu
            visualParent: pageStack
            MenuLayout {
                MenuItem {
                    text: qsTr("Copier le VDM")
                    onClicked: subTitle.copy()
                }
                MenuItem {
                    text: qsTr("Copier le URL")
                    onClicked: area_link.copy();
                }

            }
        }
    }
}
